//点击切换页面内容
let button1 = document.querySelector('li:nth-child(1)>span')
let button2 = document.querySelector('li:nth-child(3)>span')
let con1 = document.querySelector('li:nth-child(1)>div')
let con2 = document.querySelector('li:nth-child(3)>div')

button1.onclick=()=>{
  button1.classList.add('on')
  button2.classList.remove('on')
  con1.classList.remove('conceal')
  con2.classList.add('conceal')
}
button2.onclick=()=>{
  button2.classList.add('on')
  button1.classList.remove('on')
  con2.classList.remove('conceal')
  con1.classList.add('conceal')
}
//输入框效果
let urs= document.querySelector('.urs input')
let pwd= document.querySelector('.pwd input')
urs.oninput=()=>{
  if(urs.value.length)
    document.querySelector('.urs').classList.add('active')
  else
    document.querySelector('.urs').classList.remove('active')
}
pwd.oninput=()=>{
  if(pwd.value.length)
    document.querySelector('.pwd').classList.add('active')
  else
    document.querySelector('.pwd').classList.remove('active')
}

let close1 = document.querySelector('.urs>span')
let close2 = document.querySelector('.pwd>span')
close1.onclick=()=>{
  urs.value=''
}
close2.onclick=()=>{
  pwd.value=''
}
//提示框
let submit = document.querySelector('.login-screen button')
let popup = document.querySelectorAll('.tips p')
let timerId = null
submit.onclick=()=>{
  timerId = setTimeout(function(){
    popup.forEach((li)=>{
      li.classList.remove('on')
    })
  },2000)
  if(urs.value.length<6 || urs.value.length>20){
    popup[0].classList.add('on')
  }else if(pwd.value.length<6 || pwd.value.length>12){
    popup[1].classList.add('on')
  }else{
    popup[2].classList.add('on')
    timerId = setTimeout(function(){
      popup.forEach((li)=>{
        location='./index.html'
      })
    },2000)
  }
}